package com.junmeng.retrofitdemo.app

import android.app.Activity
import android.app.Application
import android.os.Bundle

class BaseApplication: Application() {

    override fun onCreate() {
        super.onCreate()

        registerActivityLifecycleCallbacks()
    }

    /**
     * 监听activity生命周期
     */
    private fun registerActivityLifecycleCallbacks() {
       registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks{
           override fun onActivityPaused(activity: Activity) {

           }

           override fun onActivityStarted(activity: Activity) {

           }

           override fun onActivityDestroyed(activity: Activity) {

           }

           override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {

           }

           override fun onActivityStopped(activity: Activity) {

           }

           override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {

           }

           override fun onActivityResumed(activity: Activity) {
              CurrentActivityManager.instance.currentActivity=activity
           }

       })
    }
}